import {observable, computed, action} from 'mobx'
import {createContext} from 'react'
import ChildrenPageUtils from '@/store/extends'
import {uSelectDevStatusAndSimpleData} from '@/api/setting'

class Devbaseinfo extends ChildrenPageUtils {
  @observable pageQuery: {devId: string; isManage: '是' | '否'} = {
    devId: '',
    isManage: '否'
  }

  @observable pageData: Setting.DevBaseInfo | null = null

  @action.bound
  async updatePageDataSource() {
    let res = await uSelectDevStatusAndSimpleData({
      devId: this.pageQuery.devId
    })
    if (res && res.result === 'success') {
      this.pageData = res.data
    } else {
      this.pageData = null
    }
  }

  @action.bound
  clearDataPage() {
    this.pageData = null
    this.pageQuery = {devId: '', isManage: '否'}
  }
}
export const devBaseInfoStore = createContext(new Devbaseinfo())
